package com.flysh.host.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class DaoUtil {
	
	private static String username="root";
	private static String password="root";
	private static String url="jdbc:mysql://localhost:3306/my";
	
	
	static{
		try {
			Class.forName("com.mysql.jdbc.Driver");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}
	
	
	public static Connection getConnection(){
		Connection con = null;
		try {
			 con = DriverManager.getConnection(url,username,password);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		return con;
	}
	
	
	public static void close(Connection conn,Statement st,ResultSet rs){
		
		try {
			
			
			if(rs!=null){
				rs.close();
				rs = null;
			}
			
			if(st!=null){
				st.close();
				st = null;
			}
			
			if(conn!=null){
				conn.close();
				conn = null;
			}
			
			
			
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
	}

}
